package charts; 
import charts.series.Element;
import charts.series.bars.Sketch;
import charts.Structs.BarSketchStyleStruct;
import string.Utils;

class BarSketch extends BarBase<BarSketchStyleStruct, Sketch> {
	
	var outline_colour:Float;
	var offset:Float;
	
	public function new( json:Dynamic, group:Float ) {
		
		//
		// these are specific values to the Sketch
		// and so we need to sort them out here
		//
		var style:BarSketchStyleStruct = {
			outline_colour		: "#000000",
			offset			: 6
		};
		
		Object_helper.merge_2( json, style );
		
		super( style, group );
	}

	//
	// called from the base object
	//
	override function get_element( index:Float, value:Dynamic ): Sketch {
		
		var default_style:Dynamic = this.get_element_helper( value );
		
		// our parent colour is a number, but
		// we may have our own colour:
		if( Std.is( default_style.colour, String) )
			default_style.colour = Utils.get_colour( default_style.colour );
			
		if ( !default_style.outline_colour )
			default_style.outline_colour = this.style.outline_colour;
			
		if( Std.is( default_style.outline_colour, String) )
			default_style.outline_colour = Utils.get_colour( default_style.outline_colour );
		
		if ( !default_style.offset )
			default_style.offset = this.style.offset;

		return new Sketch( index, default_style, this.group );
	}
}
